package com.gxan.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.gxan.common.R;
import com.gxan.pojo.RegistrationResults;
import com.gxan.service.ResumeService;
import com.gxan.service.impl.ResumeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/resume/queryRegistrationResults")
public class QueryRegistrationResultsServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获取前端传递过来的参数
        Integer id = Integer.valueOf(request.getParameter("id"));
        //传递Servic处理获取返回值
        R<RegistrationResults> registrationResultsR = new R<>();
        ResumeService resumeService = new ResumeServiceImpl();
        R r = resumeService.queryRegistrationResultsById(id);
        //返回数据到前端
        response.setContentType("application/json");
        response.setCharacterEncoding("utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));
        response.getWriter().flush();
        response.getWriter().close();
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
